﻿@*
    车间作业管理页面，进入页为产能预警，点击工艺显示该工艺的任务单
     create date:2019.12.24
     last edit:
   

*@

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>车间作业工艺能力预警</title>
    <link href="~/Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/js/common.js"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
</head>
<body>
    <script>
        openTabFormat = function (subtitle, url, icon) {
            var action = '<a href="javascript:void(0)" onclick="window.parent.addTab(\'{0}\',\'{1}\')">查看</a>';
            var htmls = stringFormat(action, subtitle, url);
            // console.log(htmls);
            return htmls;
        }

        //周列显示样式处理函数
        function valuedisplay(value, row, index) {
            a = parseFloat(value).toFixed(1);
            p = value * 100 / (row.daytime * 6) > 100 ? 100 : value * 100 / (row.daytime * 6);
            if (value > row.alertvalue * row.daytime * 6 / 100) {
                return '<div style="width:' + p + '%;height:20px;  line-height: 22px;  position:relative;background:red; "> <span style="text-align:right;  font-size: 14px; width:75px; position:absolute; ">' + a + '</span></div>';
            } else {
                return '<div style="width:' + p + '%;height:20px; line-height: 22px;   position:relative;background:green; "> <span style="text-align:right; font-size: 14px; width:75px; position:absolute; ">' + a + '</span></div>';
            }
        }
        //月视图列显示样式处理函数
        function monthvaluedisplay(value, row, index) {
            a = parseFloat(value).toFixed(1);
            p = value * 100 / (row.daytime * 25) > 100 ? 100 : value * 100 / (row.daytime * 25);
            if (value > row.alertvalue * row.daytime * 25 / 100) {
                return '<div style="width:' + p + '%;height:20px;  line-height: 22px;  position:relative;background:red; "> <span style="text-align:right; width:75px; font-size: 14px; position:absolute; ">' + a + '</span></div>';
            } else {
                return '<div style="width:' + p + '%;height:20px; line-height: 22px; position:relative;background:green; "> <span style="text-align:right; width:75px; font-size: 14px; position:absolute; ">' + a + '</span></div>';
            }
        }

        //预定义列格式,opergroupid,opergroupname,daytime,alertvalue
        var Colums = [
                { field: 'opergroupid', title: 'Code', hidden: true },
                  {
                      field: 'opergroupname', title: '工艺', width: 50,
                      //formatter: function (value, row, index) { return largefont(value, row, index); }
                  },
                   { field: 'alertvalue', title: '预警%', hidden: true },
                    {
                        field: 'daytime', title: '周能力', width: 40,
                        formatter: function (value, row, index) { return value * 6; }
                    },
                        {
                            field: 'lastweek', title: '上周', width: 80,
                            formatter: function (value, row, index) {
                                return valuedisplay(value, row, index);
                            }
                        }, {
                            field: 'thisweek', title: '本周', width: 80,
                            formatter: function (value, row, index) {
                                return valuedisplay(value, row, index);
                            }
                        }, {
                            field: 'nextweek', title: '下周', width: 80,
                            formatter: function (value, row, index) {
                                return valuedisplay(value, row, index);
                            }
                        },
                   {
                       field: 'weektime', title: '月能力', width: 40,
                       formatter: function (value, row, index) { return row.daytime * 25; }
                   }, {
                       field: 'lastmonth', title: '上月', width: 80, formatter: function (value, row, index) {
                           return monthvaluedisplay(value, row, index);
                       }
                   }, {
                       field: 'thismonth', title: '本月', width: 80, formatter: function (value, row, index) {
                           return monthvaluedisplay(value, row, index);
                       }
                   }, {
                       field: 'nextmonth', title: '下月', width: 80, formatter: function (value, row, index) {
                           return monthvaluedisplay(value, row, index);
                       }
                   }, {
                       width: 100, title: '操作', field: '_operate', formatter:
                          function (val, row, index) {
                              return openTabFormat('任务单-' + row.opergroupname, '/Produce/ShopJobList?view=pSearch&opergroupid=' + row.opergroupname)
                          }
                   }
        ];
        var removefinished = true;//周表移除已完成订单
        function shopJobOper_datagrid() {
            //if (!refresh) { refresh = false; }
            $("#shopJobOper_dg").datagrid({
                url: "/CapacityEst/getShopJobOperAlert?r=" + Math.random(),
                queryParams: {
                    //key: 'datarows',
                    //cycle: "week",
                    //adjustNum: _week_all_adjust,
                    removefinished: removefinished,
                    //refresh: refresh,
                    //classifyOper: true,
                    //schedule: $('#schedule').val(),//排程方式
                    //department: $('#Department').val()
                },
                striped: true, rownumbers: true, pagination: false, pageSize: 20, singleSelect: true,
                fitColumns: true, fit: false,//自适应
                pageList: [20, 40, 60, 80, 100],
                //frozenColumns: [],
                columns: [Colums],
                //禁止行选中
                onClickRow: function () {
                    $('#shopJobOper_dg').datagrid('clearSelections');
                },
                toolbar: [
                //    {
                //    text: '上一周',
                //    iconCls: 'icon-arrow_left',
                //    handler: function () {
                //        week_all_adjust--;
                //        week_all_datagrid(week_all_adjust);
                //    }
                //}, {
                //    text: '下一周',
                //    iconCls: 'icon-arrow_right',
                //    handler: function () {
                //        week_all_adjust++;
                //        week_all_datagrid(week_all_adjust);
                //    }
                //}, {
                //    text: '本周',
                //    iconCls: 'icon-arrow_undo',
                //    handler: function () {
                //        week_all_adjust = 0;
                //        week_all_datagrid(week_all_adjust);
                //    }
                //},
                {
                    text: '刷新',
                    iconCls: 'icon-arrow_refresh',
                    handler: function () {
                        shopJobOper_datagrid();
                    }
                }, '-', { text: '过滤已完成订单:' }, {
                    id: 'sb_all'
                }, '-',
                 //{
                 //    text: '导出',
                 //    iconCls: 'icon-page_excel',
                 //    handler: function () { exportDgData("week_all_time"); }
                 //},
                ],
                onLoadSuccess: function (data) {
                    $('#sb_all').switchbutton({
                        checked: removefinished,
                        onText: '是',
                        offText: '否',
                        onChange: function (checked) {
                            removefinished = checked;
                            shopJobOper_datagrid();
                        }

                    });
                }
            });
        }

        $(function () {
            shopJobOper_datagrid();//周产能预警
        })
    </script>
    <table id="shopJobOper_dg"></table>
</body>
</html>
